// @Author EthanScriptOn
// @Desc
package extend_parser

import (
	"fmt"
	"gitee.com/fatzeng/srf_switch_stream_bridge/bridge"
	"gitee.com/fatzeng/srf_switch_stream_bridge/framework/actuator"
	"gitee.com/fatzeng/srf_switch_stream_bridge/result_parser"
	"github.com/streadway/amqp"
)

type RabbitmqConsumeResponseParser struct {
	result_parser.BytesParser
}

func (r *RabbitmqConsumeResponseParser) Parse(ctx *actuator.SrfSwitchBridgeActuatorContext, config *bridge.BridgeConfig, response interface{}) (interface{}, error) {
	result, ok := response.(amqp.Delivery)
	if !ok {
		return nil, fmt.Errorf("response is not amqp.Delivery")
	}
	return r.BytesParser.Parse(ctx, config, result.Body)
}
